package com.lanhai.zhonglai.third;
 
import org.springframework.stereotype.Component;
 

/**
 * 扩散用的心跳
 * @author zhengwei
 *
 */
@Component
public class KSHeartThread {
	private boolean running;
	private Thread th;
	
	private byte heart ;
	
 
	
	
	public byte getHeart() {
		return heart;
	}
	
	
	public void Start( ) {
		running=true; 
		th=new Thread() { 
			@Override
			public void run(){
				while(running) {
					heart++;
					if(heart>=255) {
						heart=0;
					}
					 try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				} 
			}
			
		};
		th.start();
	}
	 
	
	public void Stop() {
		running=false;
		try {
			th.interrupt();
			th=null; 
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
}
